﻿using System;
using Microsoft.Xna.Framework;
using Terraria.Achievements;
using Terraria.UI;
using Terraria.UI.Chat;

namespace Terraria.GameContent.UI.Chat
{
	// Token: 0x02000401 RID: 1025
	public class AchievementTagHandler : ITagHandler
	{
		// Token: 0x06002411 RID: 9233 RVA: 0x0047BD84 File Offset: 0x00479F84
		TextSnippet ITagHandler.Parse(string text, Color baseColor, string options)
		{
			Achievement achievement = Main.Achievements.GetAchievement(text);
			if (achievement == null)
			{
				return new TextSnippet(text);
			}
			return new AchievementTagHandler.AchievementSnippet(achievement);
		}

		// Token: 0x06002412 RID: 9234 RVA: 0x00019895 File Offset: 0x00017A95
		public static string GenerateTag(Achievement achievement)
		{
			return "[a:" + achievement.Name + "]";
		}

		// Token: 0x02000402 RID: 1026
		private class AchievementSnippet : TextSnippet
		{
			// Token: 0x06002414 RID: 9236 RVA: 0x000198AC File Offset: 0x00017AAC
			public AchievementSnippet(Achievement achievement) : base(achievement.FriendlyName.Value, Color.LightBlue, 1f)
			{
				this.CheckForHover = true;
				this._achievement = achievement;
			}

			// Token: 0x06002415 RID: 9237 RVA: 0x000198D7 File Offset: 0x00017AD7
			public override void OnClick()
			{
				IngameOptions.Close();
				IngameFancyUI.OpenAchievementsAndGoto(this._achievement);
			}

			// Token: 0x04004021 RID: 16417
			private Achievement _achievement;
		}
	}
}
